﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CPPEI.WorkflowCore
{
    /// <summary>
    /// 流程实例
    /// </summary>
    public class Instance
    {
        public Guid Id { get; private set; }

        /// <summary>
        /// 流程当前的状态
        /// </summary>
        public State State { get; set; }

        public Workflow Workflow { get; private set; }

        /// <summary>
        /// 流程实例上所承载的业务数据。
        /// 业务数据会随着流程的不断运行产生变化，但是变化是发生在流程本身之外。
        /// 流程只使用业务数据来做某一些决策。
        /// </summary>
        public object Data { get; internal set; }

        /// <summary>
        /// 实例创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }

        /// <summary>
        /// 流程是否执行完成
        /// </summary>
        public bool IsFinished { get; set; }

        /// <summary>
        /// 流程执行完成时间
        /// </summary>
        public DateTime FinishedTime { get; set; }

        internal Instance(Guid id, Workflow workflow)
        {
            this.Id = id;
            this.Workflow = workflow;
        }

        internal Instance(Workflow workflow)
        {
            this.Id = Guid.NewGuid();
            this.Workflow = workflow;
        }
    }
}
